package tests.delete;

import static org.junit.Assert.*;

import model.Budget;
import model.BudgetFactory;
import model.Line;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.workplicity.util.Helper;
import org.workplicity.worklet.WorkletContext;

public class BudgetAndLineDeleteTest00
{
	Budget budget;
	Line line;
	BudgetFactory factory;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception
	{
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception
	{
	}

	@Before
	public void setUp() throws Exception
	{
		factory = new BudgetFactory();
		
		// Create a budget
		budget = (Budget) factory.create();
		budget.setName("Test budget");
		budget.setDescription("This is a delete test budget.");

		line = (Line) budget.createLine();
		budget.add(line);
					
		budget.commit();
	}

	@After
	public void tearDown() throws Exception
	{
	}

	@Test
	public void test()
	{
		try
		{
			Boolean successful = Helper.delete(budget, "Budgets", WorkletContext.getInstance());

			if (!successful)
				fail("Failed to delete budget with line");
		}
		catch (Exception e)
		{
			fail("Creating Budget failed with exception: " + e);
		}
	}
}